<template>
  <el-card shadow="never" class="welcome-card">
    <!-- 新增背景装饰元素 -->
    <div class="decoration">
      <div class="circle circle-1"></div>
      <div class="circle circle-2"></div>
      <div class="circle circle-3"></div>
    </div>

    <div class="welcome-container">
      <div class="logo-container">
        <!-- 添加光环动画效果 -->
        <div class="logo-halo"></div>
        <img :src="hospital.icon" class="hospital-logo">
      </div>

      <div class="welcome-text">
        欢迎来到<span class="hospital-name">{{ hospital.name }}</span>服务系统
      </div>

      <div class="sub-text">高效管理 · 智能服务 · 数据驱动</div>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import axios from "axios";
import { ElMessage } from "element-plus";

const user = ref({})
const hospital = ref({})
onMounted(() => {
  user.value = JSON.parse(sessionStorage.getItem("user") || "{}")
  initHos()
})
const initHos = () => {
  axios.get('/hospital/getHos', { params: { id: user.value.hid } }).then(res => {
    if (res.data.code == 200) {
      hospital.value = res.data.data
    } else {
      ElMessage.error(res.data.msg)
    }
  })
}
</script>

<style scoped>
.welcome-card {
  position: relative;
  border: none !important;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8f4ff 100%);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 新增装饰元素样式 */
.decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(64, 158, 255, 0.05);
}

.circle-1 {
  width: 300px;
  height: 300px;
  top: -150px;
  right: -150px;
}

.circle-2 {
  width: 200px;
  height: 200px;
  bottom: -80px;
  left: -80px;
  background: rgba(103, 194, 58, 0.05);
}

.circle-3 {
  width: 150px;
  height: 150px;
  top: 20%;
  left: 10%;
  background: rgba(230, 162, 60, 0.05);
}

.welcome-container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.logo-container {
  position: relative;
  margin-bottom: 32px;
}

.logo-halo {
  position: absolute;
  top: -15px;
  left: -15px;
  width: calc(100% + 30px);
  height: calc(100% + 30px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(64, 158, 255, 0.2) 0%, rgba(64, 158, 255, 0) 70%);
  animation: pulse 3s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.hospital-logo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 8px 25px rgba(64, 158, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: white;
  padding: 12px;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  z-index: 2;
}

.hospital-logo:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 12px 30px rgba(64, 158, 255, 0.3);
}

.welcome-text {
  font-size: 36px;
  font-weight: 500;
  color: #303133;
  line-height: 1.5;
  margin-bottom: 16px;
  animation: fadeInUp 0.8s ease-out;
  text-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.hospital-name {
  color: #409EFF;
  font-weight: 600;
  margin: 0 8px;
  position: relative;
  display: inline-block;
}

.hospital-name::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #409EFF, transparent);
  border-radius: 2px;
  animation: underline 3s infinite;
}

@keyframes underline {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

.sub-text {
  font-size: 18px;
  color: #606266;
  letter-spacing: 1px;
  margin-bottom: 40px;
  animation: fadeIn 1s ease-out 0.2s both;
  font-weight: 300;
  position: relative;
}

.sub-text::before, .sub-text::after {
  content: "✦";
  margin: 0 12px;
  color: #409EFF;
  font-size: 14px;
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* 响应式调整 */
@media (max-width: 992px) {
  .welcome-text {
    font-size: 28px;
  }
}

@media (max-width: 768px) {
  .welcome-text {
    font-size: 24px;
  }

  .hospital-logo {
    width: 120px;
    height: 120px;
  }
}

@media (max-width: 480px) {
  .welcome-container {
    padding: 20px;
  }

  .welcome-text {
    font-size: 20px;
  }

  .sub-text {
    font-size: 16px;
  }
}
</style>